using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WinSystem : Singleton<WinSystem>
{
    private void OnEnable()
    {
        ActionSystem.AttachPerformer<WinGA>(WinGAPerformer);
    }

    private void OnDisable()
    {
        ActionSystem.DetachPerformer<WinGA>();

    }
    IEnumerator WinGAPerformer(WinGA winGA)
    {
        //启动奖励view
        SetupById(winGA.id);
        return null;
    }
    //   1.计算 返回奖励 
    List<List<BagItemData>> datas;
    // public List<List<BagItemData>> GetRewardData()
    // {
    //     return new List<List<BagItemData>>
    //     {
    //         new List<BagItemData> { new XXZL(), new SJZQ(), new XXZL() },
    //         new List<BagItemData> { new Fireball(), new ArrowRain(), new Barricade() }
    //     };
    // }
    public List<List<BagItemData>> GetRewardDataById(int id)
    {
        List<List<BagItemData>> datas=MapSystem.Instance.winDict[id];
        return datas;
    }
    //   2. 打开winview 传入数据
    WinView winView;
    [SerializeField] private WinView winViewPrefab;
    [SerializeField] public Transform root;
    // public void Setup()
    // {
    //     datas = GetRewardData();
    //     //实例化
    //     winView = Instantiate(winViewPrefab, root);
    //     winView.Setup(datas);
    // }
     public void SetupById(int id)
    {
        datas = GetRewardDataById(id);
        //实例化
        winView = Instantiate(winViewPrefab, root);
        winView.Setup(datas);
    }
    public void OnClose()
    {
        Destroy(this.gameObject);
    }

}
